<template>
  <div class="list">
    <!--搜索表单-->
    <div class="common-seach-wrap">
      <el-form
        size="small"
        :inline="true"
        :model="searchForm"
        class="demo-form-inline"
      >
        <el-form-item label="审核状态">
          <el-select v-model="searchForm.status" placeholder="请选择">
            <el-option label="全部" value=""></el-option>
            <el-option label="待审核" :value="0"></el-option>
            <el-option label="审核中" :value="1"></el-option>
            <el-option label="已通过" :value="2"></el-option>
            <el-option label="未通过" :value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="onSubmit()"
            >查询</el-button
          >
        </el-form-item>
        <!-- <el-button
          size="small"
          type="primary"
          icon="el-icon-plus"
          @click="openAudit"
          >添加商品</el-button
        > -->
      </el-form>
    </div>

    <!--  <el-tabs v-model="searchForm.status" type="card" @tab-click="handleClick" class="mt16" >
      <el-tab-pane label="待审核" name="0">
        <span slot="label">待审核</span>
      </el-tab-pane>
      <el-tab-pane label="审核中" name="1">
        <span slot="label">审核中</span>
      </el-tab-pane>
      <el-tab-pane label="已通过" name="2">
        <span slot="label">已通过</span>
      </el-tab-pane>
      <el-tab-pane label="未通过" name="3">
        <span slot="label">未通过</span>
      </el-tab-pane>
    </el-tabs> -->

    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table
          size="small"
          :data="tableData"
          border
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column
            prop="goodsId"
            label="小程序商品Id"
          ></el-table-column>
          <el-table-column prop="name" label="名称"></el-table-column>
          <el-table-column label="商品封面图片">
            <template #default="scope">
              <img :src="scope.row.coverImgPath" width="30" height="30" />
            </template>
          </el-table-column>
          <el-table-column
            prop="priceTypeText"
            label="价格类型"
          ></el-table-column>
          <el-table-column
            prop="priceText"
            label="价格"
            width="200"
          ></el-table-column>
          <el-table-column
            prop="plateStatusText"
            label="平台审核状态"
            width="100"
          ></el-table-column>
          <el-table-column
            prop="auditStatusText"
            label="微信审核状态"
            width="100"
          ></el-table-column>
          <el-table-column prop="createTime" label="创建时间"></el-table-column>
          <!-- <el-table-column fixed="right" label="操作">
            <template  #default="scope">
              <el-button
                type="text"
                size="small"
                @click="openAudit(scope.row)"
                v-if="scope.row.plateAuditStatus == 0"
                >审核</el-button
              >
              <el-button
                type="text"
                size="small"
                @click="openAudit(scope.row)"
                v-if="scope.row.auditStatus == 3"
                >重新提交微信审核</el-button
              >
            </template>
          </el-table-column> -->
        </el-table>
      </div>

      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        ></el-pagination>
      </div>
    </div>
    <!--查看房间商品-->
    <!-- <audit :open="open_audit" :ruleForm="curModel" @close="closeAudit"></audit> -->
  </div>
</template>

<script>
import LiveApi from "@/api/live.js";
// import audit from "./audit.vue";

export default {
  components: {
    // audit,
  },
  inject: ["reload"],
  data() {
    return {
      /*是否加载完成*/
      loading: false,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 20,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*是否打开添加页面*/
      open_audit: false,
      /*编辑对象*/
      curModel: {},
      /*横向表单数据模型*/
      searchForm: {
        status: "",
      },
    };
  },
  created() {
    /*获取列表*/
    this.getTableList();
  },
  methods: {
    /*搜索*/
    searchSubmit() {
      this.curPage = 1;
      this.getTableList();
    },

    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.getTableList();
    },

    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getTableList();
    },

    /*切换菜单*/
    /* handleClick(tab, event) {
      let self = this;
      self.curPage = 1;
      self.getTableList();
    }, */
    /*搜索查询*/
    onSubmit() {
      let self = this;
      self.curPage = 1;
      self.getTableList();
    },

    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = self.searchForm;

      Params.pageIndex = self.curPage;
      Params.pageSize = self.pageSize;

      self.loading = true;
      LiveApi.getProductList(Params, true)
        .then((res) => {
          self.loading = false;
          self.tableData = res.data.records;
          self.totalDataNumber = res.data.total;
        })
        .catch((error) => {
          self.loading = false;
        });
    },

    /*开启商品*/
    /* openAudit(row) {
      this.curModel = row;
      this.open_audit = true;
      console.log(this.open_audit);
    }, */

    /*关闭商品*/
    /* closeAudit() {
      this.open_audit = false;
      console.log(this.open_audit);
    }, */
  },
};
</script>

<style lang="scss" scoped></style>
